package com.humble.humbleojjudgeservice.judge.codeSandbox;/*
  humble keep gonging
*/


import com.humble.humbleojjudgeservice.judge.codeSandbox.impl.ExampleSandbox;
import com.humble.humbleojjudgeservice.judge.codeSandbox.impl.RemoteSandbox;
import com.humble.humbleojjudgeservice.judge.codeSandbox.impl.ThirdPartySandbox;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 懒汉式沙箱工厂
 */
@Component
public class SandboxFactory {
    @Resource
    private RemoteSandbox remoteSandbox;

    private ThirdPartySandbox thirdPartySandbox = new ThirdPartySandbox();

    private ExampleSandbox exampleSandbox = new ExampleSandbox();
    /**
     * 构造方法私有化
     */
    public SandboxFactory(){}

    public Sandbox newInstance(String type){
        switch (type) {
            case "remote":
                return remoteSandbox;
            case "thirdparty":
                return thirdPartySandbox;
            default:
                return exampleSandbox;
        }
    }
}
